<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>QSKJ_LOCAL</title>
    <script type="text/javascript" src="/Public/Build/Cesium/Cesium.js"></script>
    <script src="/Public/js/jquery-3.7.1.min.js"></script>
    <script src="/Public/js/utilsForCesium.js"></script>
    <link rel="stylesheet" href="/Public/Build/Cesium/Widgets/widgets.css">
    <style>
        .camera-info {
            position: absolute;
            display: flex;
        }

        .camera-info>span {
            margin-left: 20px;
            color: white;
            font-size: 20px;
            font-weight: 800;
            z-index: 450;
        }
    </style>
</head>

<body>
    <div id="cesiumContainer">
        <div class="camera-info">
            <span id="c-heading"></span>
            <span id="c-pitch"></span>
            <span id="c-jd"></span>
            <span id="c-wd"></span>
            <span id="c-height"></span>
        </div>
    </div>
    <script>
        Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI0MjczNDgzMy1hYzE1LTRjNWYtODZhMS01MjZkNWRiMDc2MmUiLCJpZCI6ODIxMzAsImlhdCI6MTY0NDU0ODc0M30.LpGXXWsbQXucV5MTeC2g8BCAQWiZp612gosWcK-7ocE';

        const viewer = new Cesium.Viewer('cesiumContainer', {
            terrain: Cesium.Terrain.fromWorldTerrain(),
        });

        regCameraInfo(viewer);
        const timeCallback = new Cesium.CallbackProperty(function (time) {
            return Cesium.Color.fromRandom({ alpha: 1.0 }); // 返回一个随机颜色作为示例
        }, false);

        const entity = viewer.entities.add({
            position: Cesium.Cartesian3.fromDegrees(100, 40.0),
            point: {
                pixelSize: 10,
                color: timeCallback, // 使用CallbackProperty作为颜色属性
            },
        });


        function rotateEntity(instance, _rotation, _amount) {
            instance.rotation = new Cesium.CallbackProperty(function () {
                _rotation += _amount;
                // if (_rotation >= 360 || _rotation <= -360) {
                //     _stRotation = 0;
                // }
                return Cesium.Math.toRadians(_rotation) * 0.1;
            }, false)
        }
        // 旋转椭圆
        let ellipseRotate = viewer.entities.add({
            position: Cesium.Cartesian3.fromDegrees(113.9236839, 22.528061),
            id: 'ellipseRotateTest',
            ellipse: {
                semiMinorAxis: 50000.0,
                semiMajorAxis: 100000.0,
                // material: new Cesium.Color(1.0, 1.0, 0.0, 1.0),
                material: new Cesium.ImageMaterialProperty({
                    image: "/Public/imgs/lake-bib.png"
                }),
            }
        })

        rotateEntity(ellipseRotate.ellipse, 0, 1);



        viewer.camera.setView({
            destination: Cesium.Cartesian3.fromDegrees(
                86.33, 13.31,
                4295400
            ),
            orientation: {
                heading: Cesium.Math.toRadians(33.74),
                pitch: Cesium.Math.toRadians(-64.57),
                roll: 0.0,
            },
        });
    </script>
    </div>
</body>

</html>